package dome;

import java.util.function.DoubleUnaryOperator;

abstract class Animal{
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

   public abstract void eat();

}
interface Ifly{
    void fly();
}
interface  IRun{
    void run();
}
interface  ISwim{
    void swim();
}
class  Dog extends Animal implements IRun{
    public  Dog(String name,int age){
        super(name,age);
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃狗粮");
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在用四个腿跑");
    }
}
class  Frog extends Animal implements IRun,ISwim{
    public Frog(String name,int age){
        super(name,age);
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃蛙粮");
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在用俩个腿跳着跑");
    }

    @Override
    public void swim() {
        System.out.println(this.name+"正在蛙泳!!");
    }
}
class Duck extends Animal implements IRun,ISwim,Ifly{

    public Duck(String name,int age) {
        super(name,age);
    }

    @Override
    public void eat() {
        System.out.println(this.name+"正在吃鸭粮");
    }

    @Override
    public void fly() {
        System.out.println(this.name+"正在用翅膀煽动着跑");
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在用两只脚划着游泳");
    }

    @Override
    public void swim() {
        System.out.println(this.name+"正在用两只脚划着游泳");
    }
}
public class Test {
    public  static void fun1(Animal animal){
        animal.eat();
    }
    public static void run(IRun iRun){
        iRun.run();
    }
    public static void fly(Ifly ifly){
        ifly.fly();
    }
    public static void swim(ISwim iSwim){
        iSwim.swim();
    }

    public static void main(String[] args) {
       run(new Duck("唐老鸭",12));
        run(new Dog("二狗子",13));
        run(new Frog("青蛙",14));
        System.out.println("===========");
      fly(new Duck("唐老鸭",12));
        swim(new Duck("唐老鸭",13));
        swim(new Frog("青蛙",14));
    }
    public static void main1(String[] args) {
        fun1(new Duck("唐老鸭",12));
        fun1(new Dog("二狗子",13));
        fun1(new Frog("青蛙",14));

    }

}
